package bsf.baseservice.businessmq.systemruntime;

import bsf.util.NetworkUtil;

import java.util.Random;
import java.util.UUID;

/**
 一般类库
 
*/
public class CommonHelper
{
	/** 
	 生成相对唯一的guidid long类型
	 
	 @return 
	*/
	public static long generateIntID()
	{
		/*
		byte[] buffer = UUID.randomUUID().toString().ToByteArray();
		return BitConverter.ToInt64(buffer, 0);*/
		Random rd = new Random(UUID.randomUUID().hashCode());
		return rd.nextLong();
	}
	/** 
	 获取订阅路径
	 
	 @param mqpath
	 @return 
	*/
	public static String getSubscribeChannelPath(String mqpath)
	{
		return SystemParamConfig.Redis_Channel + "." + mqpath.toLowerCase();
	}
	/** 
	 获取当前服务器默认ip信息
	 
	 @return 
	*/
	public static String getDefaultIP()
	{
		try
		{
		   return 	NetworkUtil.getLocalIp();
		}
		catch (Exception exp)
		{
		}
		return "";
	}
}